/* FrameRater 0.1
** Actionscript 3 frame rate meter with graph
**
** Author: Pierluigi Pesenti
** http://blog.oaxoa.com
**
** Feel free to use or redistribute but please leave this credits
*/

package {

	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.text.*;
	import flash.utils.getTimer;

	public class FrameRater extends Sprite {

		private var _fps:int=0;
		private var oldTime:Number=0;
		private var currentTime:Number;
		public function FrameRater() {
			addEventListener(Event.ENTER_FRAME, onFrame);
		}
		public function get fps():int
		{
			return _fps;
		}
		private function onFrame(event:Event):void {
			currentTime=getTimer();
			_fps=1/(currentTime-oldTime)*1000;
			oldTime=currentTime;
		}
	}
}